package com.example.springboot_springsecurity_jwt_redis.common;

public enum ResultCodeEnum {
    RESULT_CODE_SUCCESS(101, "成功"),
    RESULT_CODE_FAILURE(102, "失败"),
    RESULT_CODE_USER_NEED_AUTHORITIES(201, "用户未登录"),
    RESULT_CODE_USER_LOGIN_FAILED(202, "用户账号或密码错误"),
    RESULT_CODE_USER_LOGIN_SUCCESS(203, "用户登录成功"),
    RESULT_CODE_USER_NO_ACCESS(204, "用户无权访问"),
    RESULT_CODE_USER_LOGOUT_SUCCESS(205, "用户登出成功"),
    RESULT_CODE_TOKEN_IS_BLACKLIST(206, "此token为黑名单"),
    RESULT_CODE_LOGIN_IS_OVERDUE(207, "登录已失效");

    private Integer code;
    private String message;

    private ResultCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ResultCodeEnum parse(int code) {
        ResultCodeEnum[] values = values();
        ResultCodeEnum[] var2 = values;
        int var3 = values.length;

        for(int var4 = 0; var4 < var3; ++var4) {
            ResultCodeEnum value = var2[var4];
            if (value.getCode() == code) {
                return value;
            }
        }

        throw new RuntimeException("Unknown code of ResultEnum");
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }
}
